<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
    components: {
        SelectImageRadio: async () =>
            Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectImageRadio()),
    },
    data() {
        return {
            appWindow: window,
            form: {
            },
            // 得到所有奖励
            lottery: [],

            // 选择要返回的奖励
            myLottery: [],
            // 回显选择过的奖励名称
            list: [],
            // 数据容器
            dataList: []
        };
    },
    methods: {
        // 
        async getdata() {
            console.log(this.type);
            let res = await this.$vFN.Http.post({
                url: "admin/active/activeDetail",
                data: {
                    id: this.id,
                }
            }, window);
            if(this.type == 'yes') {
                this.dataList = res.data.lottery.winning_reward;
            }else if(this.type == 'no'){
                this.dataList = res.data.lottery.loser_reward;
            }else if(this.type == 'welfare') {
                this.dataList = res.data.team_leader_award;
            }

            this.dataList.forEach(item => {
                this.myLottery.push(item);
                this.list.push(item.name)
            });
            
        },
        // 确定后返回的数据
        sum() {
            this.mixinEdit_editVisible = false;
            this.onSuccess(this.myLottery);
        },
        // 选择资产操作
        select(item, index) {
            this.list.push(item.name);
            this.myLottery.push(item);
        },
        // 获取资产
        async welfare() {
            // 抽中会员/未抽中会员奖励
            let res = await this.$vFN.Http.post({
                url: "admin/active/teamCanSelect",
            }, window);
            this.lottery = res.data;
        },
        // 初始化
        async init() {
            // btnType 用来判断点击的是添加按钮还是编辑按钮
            if(this.btnType == 'update') {
                this.getdata();
            }
            
            this.welfare();
            // 显示窗口
            this.mixinEdit_editVisible = true;
        },
        cacel() {
            this.mixinEdit_editVisible = false;
        },
        onSuccess() {

        },

    },
    mounted() {
        this.init();
    },
    activated() {},
};
</script>